package com.zb.util;

import com.zb.enums.SmsType;
import com.zb.exception.SMSException;
import com.zb.service.SmsVerificCodeService;

/**
 * 短信验证码服务类
 * @Author WEN
 * @Date 2023/7/10 0010
 **/
public class MobileUserSmsUtil {

    /**
     * 发送注册类验证码
     * @param phone 手机号
     * @throws SMSException
     */
    public static void sendRegisterVerificCode(String phone) throws SMSException {
        SmsVerificCodeService.sendVerificCode(SmsType.USER_MOBILE_REGISTER.getType(), phone);
    }

    /**
     * 校验注册验证码
     * @param phone 手机号
     * @param code 验证码
     * @throws SMSException
     */
    public static void checkRegisterVerificCode(String phone, String code) throws SMSException {
        SmsVerificCodeService.checkVerificCode(SmsType.USER_MOBILE_REGISTER.getType(), phone, code);
    }

    /**
     * 发送登录类验证码
     * @param phone 手机号
     * @throws SMSException
     */
    public static void sendLoginVerificCode(String phone) throws SMSException {
        SmsVerificCodeService.sendVerificCode(SmsType.USER_MOBILE_LOGIN.getType(), phone);
    }

    /**
     * 校验验证码
     * @param phone 手机号
     * @param code 验证码
     * @throws SMSException
     */
    public static void checkLoginVerificCode(String phone, String code) throws SMSException {
        SmsVerificCodeService.checkVerificCode(SmsType.USER_MOBILE_LOGIN.getType(), phone, code);
    }

    /**
     * 发送修改类验证码
     * @param phone 手机号
     * @throws SMSException
     */
    public static void sendUpdateVerificCode(String phone) throws SMSException {
        SmsVerificCodeService.sendVerificCode(SmsType.USER_MOBILE_UPDATE.getType(), phone);
    }

    /**
     * 校验验证码
     * @param phone 手机号
     * @param code 验证码
     * @throws SMSException
     */
    public static void checkUpdateVerificCode(String phone, String code) throws SMSException {
        SmsVerificCodeService.checkVerificCode(SmsType.USER_MOBILE_UPDATE.getType(), phone, code);
    }

    /**
     * 查询类的验证码
     * @param phone
     */
    public static void selectCode(String phone) throws SMSException {
        SmsVerificCodeService.sendVerificCode(SmsType.USER_MOBILE_SELECT.getType(), phone);
    }

    /**
     * 校验验证码
     * @param phone 手机号
     * @param code 验证码
     * @throws SMSException
     */
    public static void checkSelectVerificCode(String phone, String code) throws SMSException {
        SmsVerificCodeService.checkVerificCode(SmsType.USER_MOBILE_SELECT.getType(), phone, code);
    }
}
